package org.ccu.eshop.utils;

import org.ccu.eshop.domain.dto.CartVo;
import org.ccu.eshop.domain.dto.MemberVo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class SessionUtil {

    /**
     * 获得用户登录信息
     * @param request
     * @return
     */
    public static MemberVo getLoginMemberInfo(HttpServletRequest request){
        HttpSession session=request.getSession();
        Object obj=session.getAttribute("loginMember");
        MemberVo memberVo=(MemberVo)obj;
        return memberVo;
    }

    /**
     * 获得购物车信息
     * @param request
     * @return
     */
    public static CartVo getShopCarInfo(HttpServletRequest request){
        HttpSession session=request.getSession();
        Object obj=session.getAttribute("shopCart");
        CartVo cartVo=(CartVo) obj;
        return cartVo;
    }

}
